home *** CD-ROM | disk | FTP | other *** search
- rem secret message
-
- cls
- let pos = 1
- let counter = 0
-
- begin:
- Print "Do you wish to encrypt or "
- Print "unencrypt a sentence?"
- Print "1. Encrypt"
- Print "2. Unencrypt"
- Input selection
- If selection < 1 or selection > 2 then goto begin
-
- If selection = 1 then
- scheme$ = "encrypted"
- gosub entertext
- gosub encrypt
- endif
-
- If selection = 2 then
- scheme$ = "unencrypted"
- gosub entertext
- gosub unencrypt
- endif
-
- end
-
- entertext:
- Print "Please enter the sentence to be"
- Print scheme$
- Input sentence$
-
- Let sentencelength = len(sentence$)
- return
-
- encrypt:
- rem create an array that is equal on both sides
- let size = (int(sqr(sentencelength))) + 1
- Dim Encoder$(size,size)
- rem store the letters in the array
- For R = 1 to size
- for C = 1 to size
- if sentencelength > 0 then
- let letter$ = mid$(sentence$,pos,1)
- let encoder$(R,C) = letter$
- endif
- pos = pos + 1
- sentencelength = sentencelength - 1
-
- if sentencelength < 0 then
- let letter$ = "*"
- let encoder$(R,C) = letter$
- endif
- next C
- next R
-
- rem print out the encryption grid
- Print
- Print "you encryption grid is:"
- Print
- For C = 1 to size
- For R = 1 to size
- print encoder$(R,C);
- print " ";
- let counter = counter + 1
- if counter = size then
- print
- let counter = 0
- endif
- Next R
- Next C
-
- rem print out the sentence
- Print
- Print "Your encrypted sentence is:"
- Print
- For C = 1 to size
- For R = 1 to size
- print encoder$(R,C);
- Next R
- Next C
-
- return
-
- return
-
- unencrypt:
- rem create the array that is equal on both sides
- let size = sqr(sentencelength)
- Dim Encoder$(size,size)
- rem store the sentence
- let pos = 1
- for C = 1 to size
- for R = 1 to size
- let letter$ = mid$(sentence$,pos,1)
- let encoder$(R,C) = letter$
- let pos = pos + 1
- next R
- next C
-
- rem print out the good sentence
- Print
- Print "Your unencrypted sentence is:"
- Print
- For R = 1 to size
- For C = 1 to size
- if encoder$(R,C) <> "*" then
- print encoder$(R,C);
- endif
- next C
- next R
-
- return
-